<template>
	<view v-if="pageShow">
		<view class="block">
			<view class="xiaobai ershiba">账户余额</view>
			<view class="xiaobai fonweight margin_top2" style="font-size: 60rpx;">{{userInfo.money}}元</view>
		</view>
		<view class="mainpadding ffffff block2">
			<view class="titletext fonweight zhonghei">卡号</view>
			<input class="input margin_top" placeholder="请输入充值卡号" type="number" v-model="account"/>
			<view class="titletext fonweight zhonghei margin_top">密码</view>
			<input class="input margin_top" placeholder="请输入充值卡密码" type="password"  v-model="password"/>
		</view>
		<view class="gudingdb mainpadding flexbetween">
			<view class="czbtn flexcenter" @click="tzczj">充值记录</view>
			<view class="ljcz flexcenter" @click="submit">立即充值</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				userInfo: {},
				pageShow:false,
				account:"",
				password:"",
			}
		},
		onLoad() {
			this.userinfomsg()
		},
		methods: {
			userinfomsg() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
					this.pageShow = true
				})
			},
			submit(){
				if(this.account==""){
					httpRequest.toast("请输入充值卡号")
					return false
				}
				if(this.password==""){
					httpRequest.toast("请输入充值卡密码")
					return false
				}
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/user/giftToMoney', 'GET', {
					account:this.account,
					password:this.password,
				}).then(res => {
					uni.hideLoading()
					httpRequest.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
				})
			},
			// 跳转充值记录
			tzczj() {
				uni.navigateTo({
					url: '/pages_mypage/chongzhijl'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.ljcz {
		width: 328rpx;
		height: 76rpx;
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 800;
		background-color: #FF7510;
		border: 2rpx solid #FF7510;
		border-radius: 6rpx;
		color: #FFFFFF;
	}

	.czbtn {
		width: 328rpx;
		height: 76rpx;
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 800;
		background-color: #fff2e8;
		border: 2rpx solid #FF7510;
		border-radius: 6rpx;
		color: #FF7510;
	}

	.input {
		background: #F6F6F6;
		border-radius: 6rpx 6rpx 6rpx 6rpx;
		padding: 30rpx;
	}

	.block2 {
		border-radius: 16rpx 16rpx 0 0;
		position: relative;
		top: -20rpx;
	}

	.block {
		padding: 40rpx 30rpx 40rpx;
		background-image: url('https://kuaixun.yuntaiqikeji.com/uploads/20240120/b104f737af23f7badda74ea9e1c5e741.png');
	}
</style>